package com.sc.study.clazz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sc.common.annotation.Log;
import com.sc.common.core.controller.BaseController;
import com.sc.common.core.domain.AjaxResult;
import com.sc.common.enums.BusinessType;
import com.sc.study.clazz.domain.ScClazzPersonType;
import com.sc.study.clazz.service.IScClazzPersonTypeService;
import com.sc.common.utils.poi.ExcelUtil;
import com.sc.common.core.page.TableDataInfo;

/**
 * 班级人员类型Controller
 * 
 * @author sc
 * @date 2022-03-14
 */
@RestController
@RequestMapping("/study/clazzpersontype")
public class ScClazzPersonTypeController extends BaseController
{
    @Autowired
    private IScClazzPersonTypeService scClazzPersonTypeService;

    /**
     * 查询班级人员类型列表
     */
    @PreAuthorize("@ss.hasPermi('study:clazzpersontype:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScClazzPersonType scClazzPersonType)
    {
        startPage();
        List<ScClazzPersonType> list = scClazzPersonTypeService.selectScClazzPersonTypeList(scClazzPersonType);
        return getDataTable(list);
    }

    /**
     * 导出班级人员类型列表
     */
    @PreAuthorize("@ss.hasPermi('study:clazzpersontype:export')")
    @Log(title = "班级人员类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScClazzPersonType scClazzPersonType)
    {
        List<ScClazzPersonType> list = scClazzPersonTypeService.selectScClazzPersonTypeList(scClazzPersonType);
        ExcelUtil<ScClazzPersonType> util = new ExcelUtil<ScClazzPersonType>(ScClazzPersonType.class);
        util.exportExcel(response, list, "班级人员类型数据");
    }

    /**
     * 获取班级人员类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('study:clazzpersontype:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(scClazzPersonTypeService.selectScClazzPersonTypeById(id));
    }

    /**
     * 新增班级人员类型
     */
    @PreAuthorize("@ss.hasPermi('study:clazzpersontype:add')")
    @Log(title = "班级人员类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScClazzPersonType scClazzPersonType)
    {
        return toAjax(scClazzPersonTypeService.insertScClazzPersonType(scClazzPersonType));
    }

    /**
     * 修改班级人员类型
     */
    @PreAuthorize("@ss.hasPermi('study:clazzpersontype:edit')")
    @Log(title = "班级人员类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScClazzPersonType scClazzPersonType)
    {
        return toAjax(scClazzPersonTypeService.updateScClazzPersonType(scClazzPersonType));
    }

    /**
     * 删除班级人员类型
     */
    @PreAuthorize("@ss.hasPermi('study:clazzpersontype:remove')")
    @Log(title = "班级人员类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scClazzPersonTypeService.deleteScClazzPersonTypeByIds(ids));
    }
}
